import { Component, OnInit } from '@angular/core';
import { FormControl, FormGroup } from '@angular/forms';
import { Router } from '@angular/router';
import { User } from '../model/data.model';

@Component({
  selector: 'app-login',
  templateUrl: './login.component.html',
  styleUrls: ['./login.component.scss']
})
export class LoginComponent implements OnInit {
  public user: User | undefined;
  public loginResponse: boolean = false;

  userForm = new FormGroup({
    user_username: new FormControl(''),
    user_password: new FormControl('')
  });
  constructor(
    private router: Router
  ) { }

  ngOnInit(): void {
  }

  onSubmit() {
    this.user=this.userForm.value;
    window.localStorage["displayUserName"] = this.user?.user_username;
    this.router.navigate(['./homepage'],
    {
      state: {
        user_username: this.user?.user_username
      }
    });
  }

}
